using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using Admaco.Data;

public partial class InformeConLat : System.Web.UI.MobileControls.MobilePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Obtengo el identificador del analisis del request
        String request = HttpContext.Current.Request.QueryString.Get("id");

        Analisis analisis = new Analisis();
        TConexionesLaterales anaCon = new TConexionesLaterales();
        analisis.get(Convert.ToInt32(request));
        anaCon.get(Convert.ToInt32(request));
        FicheroClasesLabel.Text = analisis.Fichero.FicheroClases;
        FicheroDatosLabel.Text = analisis.Fichero.FicheroDatos;
        FechaLabel.Text = Convert.ToString(analisis.FechaFin);
        UsuarioLabel.Text = analisis.Usuario.Nombre;
        NeuronasLabel.Text = Convert.ToString(anaCon.NumeroNeuronas);
        CoeficienteLabel.Text = Convert.ToString(anaCon.CoefiAprendizaje);
        IteracionesLabel.Text = Convert.ToString(anaCon.NumIteraciones);
        TauLabel.Text = Convert.ToString(anaCon.Tau);
        PLabel.Text = Convert.ToString(anaCon.P);
        ConclusionLabel.Text = analisis.Conclusion;

        String directorioDatos = System.Configuration.ConfigurationSettings.AppSettings["dataDirectory"];

        if (analisis.Imagen != null)
        {
            String rutaImagen = Request.PhysicalApplicationPath + @"Imagenes\image_temp.jpg";
            analisis.Imagen.Save(rutaImagen);

            Imagen.ImageUrl = Request.ApplicationPath + "/Imagenes/image_temp.jpg";
         
        }
    }
    protected void Command1_Click(object sender, EventArgs e)
    {
        HttpContext.Current.Response.Redirect("AnalisisConLat.aspx");
    }


    private void resize_image(String file, String saveFilename, int widthToUse, int heightToUse)
    {
        Bitmap bitmap = new Bitmap(file);

        // create the output bitmap
        Bitmap newBitmap = new Bitmap(widthToUse, heightToUse);

        // create a Graphics object to draw into it
        Graphics g = Graphics.FromImage(newBitmap);
        g.InterpolationMode = InterpolationMode.HighQualityBicubic;

        // draw it with the new size
        g.DrawImage(bitmap, 0, 0, widthToUse, heightToUse);

        bitmap.Dispose();

        // save the bitmap using the JPG encoder
        newBitmap.Save(saveFilename, System.Drawing.Imaging.ImageFormat.Jpeg);

        newBitmap.Dispose();
    }
}
